package io;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

public class IOUtil {
	public static String toString(String fileName) {
		File file = new File(fileName);
		try {
			return toString(new FileInputStream(file),
					Integer.valueOf(String.valueOf(file.length())));
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "";
	}

	public static String toString(InputStream in, int stringSize) {
		byte[] bs = new byte[stringSize];
		try {
			in.read(bs);
		} catch (IOException e) {
			e.printStackTrace();
		}
		return new String(bs);
	}

	public static void main(String[] args) throws Exception {
		System.out.println(toString("G:/work/test.txt"));
	}
}
